package poc;


import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
import java.net.InetAddress;
import java.net.UnknownHostException;


/**
 * Created by LiuLin on 2018/10/30.
 */
public class MyElasticsearchText {

	public final static String HOST = "localhost";
	public final static int PORT = 9300;//http请求的端口是9200，客户端是9300
	private static TransportClient client = null;

	public static void main(String[] args) throws Exception {
		client = new PreBuiltTransportClient(Settings.EMPTY).addTransportAddresses(new TransportAddress(InetAddress.getByName(HOST),PORT));
		System.out.println("连接信息:" + client.toString());
	}

	public static void closeConnet(){
		if(client != null){
			System.out.println("关闭连接。。。。");
			client.close();
		}
	}

}


